package com.example.blog.config;

import com.example.blog.model.Constants;
import com.example.blog.model.Result;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * ClassName: ErrorAdvice
 * Package: IntelliJ IDEA
 * Description:
 *
 * @Author 谷京京
 * @Create 2024/3/26 10:25
 * @Version 1.0
 */
@ResponseBody
@ControllerAdvice
public class ErrorAdvice {
    @ExceptionHandler
    public Result errorHandler(Exception e) {
        Result result = new Result<>();
        result.setErrorMeg("内部发生错误, 请联系管理员" + e.getMessage());
        result.setCode(Constants.RESLUT_ERROR);
        return result;
    }
}
